
<template>
  <el-dialog
    v-model="conf.visible"
    title="添加 地区表"
    width="30%"
    draggable
    :before-close="hide"
  >
  <el-form :model="form" size="small" ref="form" :rules="rules">

    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide">取消</el-button>
        <el-button type="primary" @click="save">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      conf: {
        visible: false,
        uploadPath:this.$theia.env.join("/file/upload"),
      },
    rules:{
    },
    form:{
        },
      }},
  methods: {
    show() {
      this.conf.visible = true;
    },
    save(){
       
        this.$refs.form.validate((v=>{
            if(v){
                this.onSave()
               
            }
        }))
    },
    onSave(){
        let that = this
        let postForm=this.form
        
        this.$theia.http.post("/areainfo",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '地区表保存成功',duration:5000})
            that.$emit("onsaved")
            that.hide()
        }).catch(res=>{
          let code = res.response.status
          let msg= `地区表保存失败(${code})`
          that.$notify.error({title: '失败',message:msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
    onUploadSuccess(response){
      
    },
  },
};
</script>

<style scoped>
.avatar-uploader .avatar {
  width: 80px;
  height: 80px;
  display: block;
}
</style>